package com.yj.wisemoms;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.google.android.gcm.GCMBaseIntentService;
import com.yj.wisemoms.R;
import com.yj.wisemoms.Disk.SaveData;
import com.yj.wisemoms.Layout.IntroActivity;
import com.yj.wisemoms.R.drawable;
import com.yj.wisemoms.Util.PushWakeLock;
import com.yj.wisemoms.Util.Setting_app;
import com.yj.wisemoms.Util.ShowMsg;
import com.yj.wisemoms.Util.ShowPush;
import com.yj.wisemoms.Util.Util;
import com.yj.wisemoms.http.newslistData;
import com.yj.wisemoms.http.registerPush;

public class GCMIntentService extends GCMBaseIntentService{
	private static final String tag = "GCMIntentService";
		
	String c2dm_msg = null;
	
	public GCMIntentService(){ this(Setting_app.pushID); }
	
	public GCMIntentService(String senderId) { super(senderId); }

	@Override
	protected void onMessage(Context context, Intent intent) {
		
		if(SaveData.getInstance(context).getInt("ispush") == 1){
			
			new ShowPush(context, intent);
		}


	}
		
	@Override
	protected void onError(Context context, String errorId) {
		Log.d(tag, "onError. errorId : "+errorId);
	}
	
	@Override
	protected void onRegistered(Context context, String regId) {
		Log.d(tag, "onregistered. regId : "+regId);
		registerPush regPush = new registerPush();
		regPush.execute(Util.getPhoneNumber(context),regId);
		SaveData.getInstance(context).save("ispush", 1);	
	}


	@Override
	protected void onUnregistered(Context context, String regId) {
		Log.d(tag, "onUnregistered. regId : "+regId);
	}

	@Override
	protected boolean onRecoverableError(Context context, String errorId) {
		Log.d(tag, "onRecoverableError. errorId : "+errorId);
		return super.onRecoverableError(context, errorId);
	}

	
	
	

}